package com.ruoyi.quan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.quan.domain.QSiteInfo;
import com.ruoyi.quan.service.IQSiteInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 站点信息Controller
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/quan/site")
public class QSiteInfoController extends BaseController
{
    @Autowired
    private IQSiteInfoService qSiteInfoService;

    /**
     * 查询站点信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(QSiteInfo qSiteInfo)
    {
        startPage();
        List<QSiteInfo> list = qSiteInfoService.selectQSiteInfoList(qSiteInfo);
        return getDataTable(list);
    }

    /**
     * 导出站点信息列表
     */
    @Log(title = "站点信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QSiteInfo qSiteInfo)
    {
        List<QSiteInfo> list = qSiteInfoService.selectQSiteInfoList(qSiteInfo);
        ExcelUtil<QSiteInfo> util = new ExcelUtil<QSiteInfo>(QSiteInfo.class);
        util.exportExcel(response, list, "站点信息数据");
    }

    /**
     * 获取站点信息详细信息
     */
    @GetMapping(value = "/{siteId}")
    public AjaxResult getInfo(@PathVariable("siteId") Long siteId)
    {
        return success(qSiteInfoService.selectQSiteInfoBySiteId(siteId));
    }

    /**
     * 新增站点信息
     */
    @Log(title = "站点信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QSiteInfo qSiteInfo)
    {
        return toAjax(qSiteInfoService.insertQSiteInfo(qSiteInfo));
    }

    /**
     * 修改站点信息
     */
    @Log(title = "站点信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QSiteInfo qSiteInfo)
    {
        return toAjax(qSiteInfoService.updateQSiteInfo(qSiteInfo));
    }

    /**
     * 删除站点信息
     */
    @Log(title = "站点信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{siteIds}")
    public AjaxResult remove(@PathVariable Long[] siteIds)
    {
        return toAjax(qSiteInfoService.deleteQSiteInfoBySiteIds(siteIds));
    }
} 